<template>
  <div class="discover_main">
    <div class="discover_title">
      <div class="discover_l">
        <div class="discover_title_top">{{ thatDayTotalNumber }}</div>
        <span>今日获客</span>
      </div>
      <div class="discover_r">
        <div class="discover_title_top">{{ allTotalNumber }}</div>
        <span>累计获客</span>
      </div>
    </div>
    <div class="discover_item">
      <div
        class="discover_content"
        v-for="item in articleList"
        :key="item.id"
        @click="
          $router.push(
            '/VIp/discover/discover_details?id=' + item.articleShareId
          )
        "
      >
        <div class="discover_content_img">
          <img :src="imgBaseUrl + item.headPortrait" />
        </div>
        <div class="discover_content_text">
          <div class="discover_date">{{ item.nickName }}</div>
          <div class="discover_active">
            <div class="discover_content_data singlerows">阅读文章：{{ item.articleTitle }}</div>
            {{ item.createTime }}
          </div>
        </div>
      </div>
    </div>
    <div class="pageList">
      <paging ref="paging_zi" @CurrentPage="accept_CurrentValue" />
    </div>
  </div>
</template>

<script>
import paging from "../../../components/paging.vue";
import { commonRequest, postRequest, imgBaseUrl } from "../../../api/api.js";
export default {
  name: "dscover",
  components: {
    paging
  },
  data() {
    return {
      allTotalNumber: 0, // 全部访客
      thatDayTotalNumber: 0, // 每日访客
      articleList: [], // 文章列表
      currentPage: 1, // 当前页
      sizePage: 0,
      imgBaseUrl: ""
    };
  },
  mounted() {
    // 获取文章列表
    this.imgBaseUrl = imgBaseUrl;
    this.getVisitorInfoList();
    // 获取访客记录
    this.getVisitor();
  },
  methods: {
    accept_CurrentValue: function(value) {
      console.log(value);
    },
    // 获取访客记录
    getVisitor() {
      commonRequest("/api/ums/umsArticleShare/getVisitorsTotal").then(res => {
        // console.log("访客记录", res);
        this.allTotalNumber = res.allTotal;
        this.thatDayTotalNumber = res.thatDayTotal;
      });
    },
    // 获取文章列表
    getVisitorInfoList() {
      // let token = localStorage.getItem("saasToken");
      commonRequest("/api/ums/umsVisitor/list").then(res => {
        // console.log(res);
        this.articleList = res.records;
        this.$refs.paging_zi.totalValue(res.pages);
      });
    }
  }
};
</script>

<style lang="less" scoped>
.discover_title {
  width: 900px;
  height: 80px;
  display: flex;
  align-items: center;
  background-color: #fff;
  div {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    color: #44a2ff;
    font-size: 18px;
    font-weight: 700;
  }
  span {
    color: #999999;
    font-size: 14px;
    font-weight: 400;
    margin-top: 10px;
  }
}
.discover_item {
  margin: 10px 0;
  .discover_content {
    display: flex;
    height: 100px;
    align-items: center;
    .discover_content_img {
      width: 60px;
      height: 60px;
      margin-right: 15px;
      img {
        height: 100%;
        width: 100%;
      }
    }
    .discover_content_text {
      flex: 1;
      display: flex;

      justify-content: space-evenly;
      flex-direction: column;
      .discover_date {
        color: #ccc;
        font-size: 14px;
        margin-bottom: 5px;
      }
      .discover_active {
        margin-top: 5px;
        display: flex;
        font-size: 14px;
        color: #ccc;
        justify-content: space-between;
        .discover_content_data {
          color: #000;
          width: 560px;
          font-size: 14px;
        }
      }
    }
  }
}
.pageList {
  height: 100px;
  display: flex;
  flex-direction: row-reverse;
  align-items: center;
}
</style>
